//
//  HRGoodsListCell.m
//  haierapp
//
//  Created by zhang on 14-8-8.
//  Copyright (c) 2014年 haier. All rights reserved.
//

#import "HRGoodsListCell.h"

#import "HRProListItem.h"

@implementation HRGoodsListCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(id)init{
    self=[[[NSBundle mainBundle]loadNibNamed:@"HRGoodsListCell" owner:self options:nil] objectAtIndex:0];
    
    return self;
    
}

#pragma mark - Methods
-(void)configWithData:(id)data{
    HRProListItem *product=(HRProListItem *)data;
    CGFloat price=[product.unitPrice floatValue];
    NSString *goodPraise=product.productRating;
    
    self.goodsTitle.text=product.productTitle;
    
    self.goodsPrice.text=[NSString stringWithFormat:@"￥%.2f",price];
    self.goodsPraise.text=[NSString stringWithFormat:@"好评度:%@",goodPraise];
    
    NSURL *imageUrl=[NSURL URLWithString:product.productLinker];
    [self.goodsImageView setImageWithURL:imageUrl placeholderImage:[UIImage imageNamed:IMAGENAME_PLACE_HODLE]];
    
    self.hotImageView.hidden=YES;
    self.discountImageView.hidden=YES;
    
    BOOL isActivity=[product.isActivity boolValue];
    
    if (isActivity) {
        _discountImageView.hidden=NO;
    }
    
}

@end
